<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>DialogExample</title>
    <style>
        .mask {
            position: fixed;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            top: 0px;
            left: 0px;
        }

        .dialog {
            width: 400px;
            height: 200px;
            background-color: hotpink;
            margin: 200px auto;
        }
    </style>
</head>
<body>

<div id="app">

    <button @click="flag=!flag"> show dialog</button>

    <dialog-e :show.sync="flag"></dialog-e>

</div>

<template id="dialog">
    <div class="mask" v-show="show">
        <div class="dialog">
            <button @click="change">close</button>
        </div>
    </div>
</template>

<script src="../node_modules/vue/dist/vue.js"></script>

<script>


    let dialogE = {
        template: '#dialog',
        props: ['show'],
        methods:{
            change(){
                this.$emit('update:show',!this.show)
            }
        }
    }

    let vm = new Vue({
        el: '#app',
        data: {
            flag: true,
        },
        components: {
            dialogE
        }
    })

</script>


</body>
</html>